<?php
namespace app\admin\validate;
use think\Validate;
class Link extends Validate
{
    //验证规则
    protected $rule = [
        'title'  =>  'require|max:25|unique:link',
        'url'    =>  'require|unique:link|url',
//        'desc' =>  'require',
    ];
    //错误提示
    protected $message = [
        'title.require' => '链接标题必须填写',
        'title.max'     => '链接标题长度必须小于25位',
        'title.unique'  => '链接标题不得重复',
        'url.require'   => '链接地址必须填写',
        'url.unique'    => '链接地址不得重复',
        'url.url'       => '链接地址格式不正确',
    ];
    //验证场景
    protected  $scene = [
        'add'  => ['title','url'],
        'edit' => ['title','url'],
    ];
}
